class Student(object):
    # 添加类属性，初始化学生数计数
    count = 0
    # 每次创建一个新的实例，学生数计数+1
    def __init__(self, name):
        self.name = name
        Student.count += 1

# 测试使用
if __name__ == '__main__':
    # 实例化对象1
    xiaoming = Student('xiaoming')
    # 实例化对象2
    xiaobai = Student('xiaobai')
    print(Student.count)